import ConfigParser
from google.appengine.ext import db
from RegModel import RegModel as rm

class WeiboConfigParser(object):
    def __init__(self):
        self.sina_weibo_config = ConfigParser.ConfigParser()
        try:
            self.sina_weibo_config.readfp(open('config/weibo.config'))
        except WeiboConfigParser.Error:
            print 'read config file failed.'

        self.app_key = self.sina_weibo_config.get("userinfo","APP_KEY")
        self.app_secret = self.sina_weibo_config.get("userinfo","APP_SECRET")
        self.url = self.sina_weibo_config.get("userinfo","URL")

    def getAppKey (self):
        return self.app_key

    def getAppSecret(self):
        return self.app_secret

    def getUrl(self):
        return self.url

    def getToken_TSecret(self,sender):
        ancestor = rm.get_by_key_name(sender)
        query = db.Query(ancestor).get()
        if query is not None:
            return query
        else:
            return None